Special case menu items to pop down on motion. (#75961)
authorOwen Taylor <otaylor@redhat.com>
Wed, 15 May 2002 21:46:42 +0000 (21:46 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 15 May 2002 21:46:42 +0000 (21:46 +0000)
Wed May 15 17:12:50 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtktooltips.c: Special case menu items to
        pop down on motion. (#75961)

        * tests/testgtk.c (create_item_factory): Add tooltips
        to the File menu.

        * gtk/gtkentry.c (update_im_cursor_location): Fix
        cursor locations passed to the IM context.
        (#80027, Yao Zhang)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkentry.c
gtk/gtktooltips.c
tests/testgtk.c

index e301d0d260492bbb206eb5def9b1d3278e5d8179..20a6be25d73ab4b82aec1490435466ca6e94184d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Wed May 15 17:12:50 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktooltips.c: Special case menu items to
+       pop down on motion. (#75961)
+
+       * tests/testgtk.c (create_item_factory): Add tooltips
+       to the File menu.
+
+       * gtk/gtkentry.c (update_im_cursor_location): Fix 
+       cursor locations passed to the IM context.
+       (#80027, Yao Zhang)
+
 Wed May 15 16:52:57 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfontsel.c: Update from contents of size entry
index e301d0d260492bbb206eb5def9b1d3278e5d8179..20a6be25d73ab4b82aec1490435466ca6e94184d 100644 (file)
@@ -1,3 +1,15 @@
+Wed May 15 17:12:50 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktooltips.c: Special case menu items to
+       pop down on motion. (#75961)
+
+       * tests/testgtk.c (create_item_factory): Add tooltips
+       to the File menu.
+
+       * gtk/gtkentry.c (update_im_cursor_location): Fix 
+       cursor locations passed to the IM context.
+       (#80027, Yao Zhang)
+
 Wed May 15 16:52:57 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfontsel.c: Update from contents of size entry
index e301d0d260492bbb206eb5def9b1d3278e5d8179..20a6be25d73ab4b82aec1490435466ca6e94184d 100644 (file)
@@ -1,3 +1,15 @@
+Wed May 15 17:12:50 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktooltips.c: Special case menu items to
+       pop down on motion. (#75961)
+
+       * tests/testgtk.c (create_item_factory): Add tooltips
+       to the File menu.
+
+       * gtk/gtkentry.c (update_im_cursor_location): Fix 
+       cursor locations passed to the IM context.
+       (#80027, Yao Zhang)
+
 Wed May 15 16:52:57 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfontsel.c: Update from contents of size entry
index e301d0d260492bbb206eb5def9b1d3278e5d8179..20a6be25d73ab4b82aec1490435466ca6e94184d 100644 (file)
@@ -1,3 +1,15 @@
+Wed May 15 17:12:50 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktooltips.c: Special case menu items to
+       pop down on motion. (#75961)
+
+       * tests/testgtk.c (create_item_factory): Add tooltips
+       to the File menu.
+
+       * gtk/gtkentry.c (update_im_cursor_location): Fix 
+       cursor locations passed to the IM context.
+       (#80027, Yao Zhang)
+
 Wed May 15 16:52:57 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfontsel.c: Update from contents of size entry
index e301d0d260492bbb206eb5def9b1d3278e5d8179..20a6be25d73ab4b82aec1490435466ca6e94184d 100644 (file)
@@ -1,3 +1,15 @@
+Wed May 15 17:12:50 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktooltips.c: Special case menu items to
+       pop down on motion. (#75961)
+
+       * tests/testgtk.c (create_item_factory): Add tooltips
+       to the File menu.
+
+       * gtk/gtkentry.c (update_im_cursor_location): Fix 
+       cursor locations passed to the IM context.
+       (#80027, Yao Zhang)
+
 Wed May 15 16:52:57 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfontsel.c: Update from contents of size entry
index e301d0d260492bbb206eb5def9b1d3278e5d8179..20a6be25d73ab4b82aec1490435466ca6e94184d 100644 (file)
@@ -1,3 +1,15 @@
+Wed May 15 17:12:50 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktooltips.c: Special case menu items to
+       pop down on motion. (#75961)
+
+       * tests/testgtk.c (create_item_factory): Add tooltips
+       to the File menu.
+
+       * gtk/gtkentry.c (update_im_cursor_location): Fix 
+       cursor locations passed to the IM context.
+       (#80027, Yao Zhang)
+
 Wed May 15 16:52:57 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkfontsel.c: Update from contents of size entry
index 5200bf2165fa1ec237d609085bf1fe8cb68a2445..35554e4aa4816b046af10850bcf262a4f5d793e6 100644 (file)
@@ -2367,11 +2367,11 @@ update_im_cursor_location (GtkEntry *entry)
   GdkRectangle area;
   gint strong_x;
   gint strong_xoffset;
-  gint x, y, area_width, area_height;
+  gint area_width, area_height;
 
   gtk_entry_get_cursor_locations (entry, CURSOR_STANDARD, &strong_x, NULL)
 ;
-  get_text_area_size (entry, &x, &y, &area_width, &area_height);
+  get_text_area_size (entry, NULL, NULL, &area_width, &area_height);
 
   strong_xoffset = strong_x - entry->scroll_offset;
   if (strong_xoffset < 0)
@@ -2382,9 +2382,9 @@ update_im_cursor_location (GtkEntry *entry)
     {
       strong_xoffset = area_width;
     }
-  area.x = x + strong_xoffset;
-  area.y = y + area_height;
-  area.width = area_width;
+  area.x = strong_xoffset;
+  area.y = 0;
+  area.width = 0;
   area.height = area_height;
 
   gtk_im_context_set_cursor_location (entry->im_context, &area);
index 6f37438e92333f5c58316c92b9f17f7447212690..20bc1fec643f978ce0c282995e38aa885e7e45e7 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "gtklabel.h"
 #include "gtkmain.h"
+#include "gtkmenuitem.h"
 #include "gtkwidget.h"
 #include "gtkwindow.h"
 #include "gtksignal.h"
@@ -518,6 +519,31 @@ stop_keyboard_mode (GtkWidget *widget)
     }
 }
 
+static void
+gtk_tooltips_start_delay (GtkTooltips *tooltips,
+                         GtkWidget   *widget)
+{
+  GtkTooltipsData *old_tips_data;
+  
+  old_tips_data = tooltips->active_tips_data;
+  if (tooltips->enabled &&
+      (!old_tips_data || old_tips_data->widget != widget))
+    {
+      guint delay;
+      
+      gtk_tooltips_set_active_widget (tooltips, widget);
+      
+      if (tooltips->use_sticky_delay &&
+         gtk_tooltips_recently_shown (tooltips))
+       delay = STICKY_DELAY;
+      else
+       delay = tooltips->delay;
+      tooltips->timer_tag = gtk_timeout_add (delay,
+                                            gtk_tooltips_timeout,
+                                            (gpointer) tooltips);
+    }
+}
+
 static void
 gtk_tooltips_event_handler (GtkWidget *widget,
                             GdkEvent  *event)
@@ -559,29 +585,11 @@ gtk_tooltips_event_handler (GtkWidget *widget,
   
       switch (event->type)
        {
-       case GDK_MOTION_NOTIFY:
        case GDK_EXPOSE:
          /* do nothing */
          break;
-         
        case GDK_ENTER_NOTIFY:
-         old_tips_data = tooltips->active_tips_data;
-         if (tooltips->enabled &&
-             (!old_tips_data || old_tips_data->widget != widget))
-           {
-             guint delay;
-             
-             gtk_tooltips_set_active_widget (tooltips, widget);
-             
-             if (tooltips->use_sticky_delay  &&
-             gtk_tooltips_recently_shown (tooltips))
-               delay = STICKY_DELAY;
-             else
-               delay = tooltips->delay;
-             tooltips->timer_tag = gtk_timeout_add (delay,
-                                                    gtk_tooltips_timeout,
-                                                    (gpointer) tooltips);
-           }
+         gtk_tooltips_start_delay (tooltips, widget);
          break;
          
        case GDK_LEAVE_NOTIFY:
@@ -595,6 +603,17 @@ gtk_tooltips_event_handler (GtkWidget *widget,
          }
          break;
 
+       case GDK_MOTION_NOTIFY:
+         /* Handle menu items specially ... pend popup for each motion
+          * on other widgets, we ignore motion.
+          */
+         if (GTK_IS_MENU_ITEM (widget))
+           {
+             gtk_tooltips_set_active_widget (tooltips, NULL);
+             gtk_tooltips_start_delay (tooltips, widget);
+             break;
+           }
+         break;                /* ignore */
        case GDK_BUTTON_PRESS:
        case GDK_BUTTON_RELEASE:
        case GDK_KEY_PRESS:
index 62c8036089130fedc2250fad515a81113996157c..2baf054e8679745261558df764e44e9f821c94d7 100644 (file)
@@ -3598,6 +3598,7 @@ create_item_factory (GtkWidget *widget)
       GtkWidget *button;
       GtkAccelGroup *accel_group;
       GtkItemFactory *item_factory;
+      GtkTooltips *tooltips;
       
       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
       
@@ -3628,6 +3629,23 @@ create_item_factory (GtkWidget *widget)
                                                                                      "/Preferences/Shape/Oval")),
                                      TRUE);
 
+      /* Test how tooltips (ugh) work on menu items
+       */
+      tooltips = gtk_tooltips_new ();
+      g_object_ref (tooltips);
+      gtk_object_sink (GTK_OBJECT (tooltips));
+      g_object_set_data_full (G_OBJECT (window), "testgtk-tooltips",
+                             tooltips, (GDestroyNotify)g_object_unref);
+      
+      gtk_tooltips_set_tip (tooltips, gtk_item_factory_get_item (item_factory, "/File/New"),
+                           "Create a new file", NULL);
+      gtk_tooltips_set_tip (tooltips, gtk_item_factory_get_item (item_factory, "/File/Open"),
+                           "Open a file", NULL);
+      gtk_tooltips_set_tip (tooltips, gtk_item_factory_get_item (item_factory, "/File/Save"),
+                           "Safe file", NULL);
+      gtk_tooltips_set_tip (tooltips, gtk_item_factory_get_item (item_factory, "/File/Save As..."),
+                           "Save under a new name", NULL);
+
       box1 = gtk_vbox_new (FALSE, 0);
       gtk_container_add (GTK_CONTAINER (window), box1);